package com.sys.ai.controller;

import com.sys.ai.domain.AiPlatform;
import com.sys.ai.service.IAiPlatformService;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.core.page.TableDataInfo;
import com.sys.common.enums.BusinessType;
import com.sys.common.utils.poi.ExcelUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * LLM提供平台管理Controller
 *
 * @author LGY
 * @date 2025-05-26
 */
@Tag(name = "LLM提供平台管理")
@RestController
@RequestMapping("/ai/aiPlatform")
public class AiPlatformController extends BaseController {
    @Autowired
    private IAiPlatformService aiPlatformService;

    /**
     * 查询LLM提供平台管理列表
     */
    @PostMapping("/list")
    @Operation(summary = "查询LLM提供平台管理分页列表")
    public TableDataInfo list(@RequestBody AiPlatform aiPlatform) {
        startPage(aiPlatform);
        List<AiPlatform> list = aiPlatformService.selectAiPlatformList(aiPlatform);
        return getDataTable(list);
    }

    @Operation(summary = "查询LLM提供平台管理列表")
    @GetMapping("/listAll")
    public AjaxResult listAll() {
        return AjaxResult.success(aiPlatformService.list());
    }

    /**
     * 导出LLM提供平台管理列表
     */
    @Log(title = "LLM提供平台管理", businessType = BusinessType.EXPORT)
    @Operation(summary = "导出LLM提供平台管理")
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiPlatform aiPlatform) {
        List<AiPlatform> list = aiPlatformService.selectAiPlatformList(aiPlatform);
        ExcelUtil<AiPlatform> util = new ExcelUtil<AiPlatform>(AiPlatform.class);
        util.exportExcel(response, list, "LLM提供平台管理数据");
    }

    /**
     * 获取LLM提供平台管理详细信息
     */
    @Operation(summary = "查询LLM提供平台管理详情")
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(aiPlatformService.selectAiPlatformById(id));
    }

    /**
     * 新增LLM提供平台管理
     */
    @Log(title = "LLM提供平台管理", businessType = BusinessType.INSERT)
    @Operation(summary = "新增LLM提供平台管理")
    @PostMapping("/save")
    public AjaxResult add(@RequestBody AiPlatform aiPlatform) {
        aiPlatformService.insertAiPlatform(aiPlatform);
        return success();
    }

    /**
     * 修改LLM提供平台管理
     */
    @Log(title = "LLM提供平台管理", businessType = BusinessType.UPDATE)
    @Operation(summary = "修改LLM提供平台管理")
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody AiPlatform aiPlatform) {
        aiPlatformService.updateAiPlatform(aiPlatform);
        return success();
    }

    /**
     * 删除LLM提供平台管理
     */
    @Operation(summary = "删除LLM提供平台管理")
    @Log(title = "LLM提供平台管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        aiPlatformService.deleteAiPlatformByIds(ids);
        return success();
    }
}